package com.ksyun.camp.client;

import com.ksyun.camp.config.FeignConfig;
import com.ksyun.camp.modle.dto.PayDto;
import com.ksyun.camp.modle.entity.UserAccount;
import com.ksyun.camp.modle.vo.PayVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@FeignClient(name = "fundsSystem", url = "http://120.92.116.60", configuration = FeignConfig.class)
//@FeignClient(name = "fundsSystem", url = "http://172.16.0.90", configuration = FeignConfig.class)
public interface FeinClient {

    /**
     * 初始化账户
     * @param kingstarId 学号
     * @param requestId 请求ID
     * @param accountList 用户账户列表
     *
     */
    @PostMapping("/thirdpart/onePass/initAccount")
    ResponseEntity<String> initUsersAccount(
            @RequestHeader("X-KSY-KINGSTAR-ID") Long kingstarId,
            @RequestHeader("X-KSY-REQUEST-ID") String requestId,
            @RequestBody List<UserAccount> accountList
            );

    /**
     * 充值账户
     * @param kingstarId 学号
     * @param requestId 请求ID
     *
     */
    @PostMapping("/thirdpart/onePass/resetAccountData")
    ResponseEntity<String> resetUsersAccount(
            @RequestHeader("X-KSY-KINGSTAR-ID") Long kingstarId,
            @RequestHeader("X-KSY-REQUEST-ID") String requestId
    );

    /**
     * 从资金系统对余额系统充值
     * @param kingstarId 学号
     * @param requestId  请求ID
     * @param payVo 请求账户信息
     *
     */
    @PostMapping("/thirdpart/onePass/pay")
    ResponseEntity<String> getMoneyFromUsersAccount(
            @RequestHeader("X-KSY-KINGSTAR-ID") Long kingstarId,
            @RequestHeader("X-KSY-REQUEST-ID") String requestId,
            @RequestBody PayVo payVo
            );

    /**
     * 充值成功确认
     * @param kingstarId 学号
     * @param requestId 请求ID
     * @param batchPayId 原批量充值 Id
     */
    @PostMapping("/thirdpart/onePass/batchPayFinish")
    ResponseEntity<String> ensurePaySuccess(
            @RequestHeader("X-KSY-KINGSTAR-ID") Long kingstarId,
            @RequestHeader("X-KSY-REQUEST-ID") String requestId,
            @RequestParam String batchPayId
    );

    @PostMapping("/thirdpart/onePass/batchPayBegin")
    ResponseEntity<String> batchPayBegin(
            @RequestHeader("X-KSY-KINGSTAR-ID") Long kingstarId,
            @RequestHeader("X-KSY-REQUEST-ID") String requestId,
            @RequestBody PayDto payDto
    );

}

